import unittest

import requests
from requests import Response


class BaseCase(unittest.TestCase):
    # 公共调用请求的方法
    def xn_request(self, method: str, url, data, **kwargs) -> Response:
        method = method.lower()
        headers = {"token": "aaa"} # 示例
        response_text = None
        if method == "post":
            response_text = requests.post(url=url, data=data, headers=headers)
        elif method == "get":
            response_text = requests.get(url=url, params=data, headers=headers)
        else:
            response_text = None
        # 其他的方法可以在这里添加

        # print(type(response_text))
        return response_text


if __name__ == '__main__':
    unittest.main()
